<template>
	<div class="details-container">
		<h3 class="title">{{ details.title }}</h3>
		<p>
			<span>发表时间：{{ details.add_time | dataFormat }}</span>
			<span>点击：{{ details.click }}次</span>
		</p>
		<hr>
		<!-- 留个坑,图片过期了，不是我的锅 -->
		<div>
			<p>图片地址失效了，为了功能实现，不好意思</p>
			<img v-for="item in Thumbs" src="../../../image/shuijiao.jpg" :key="item.img_url" />
		</div>
		<!-- 说明文字 -->
		<div class="details-content" v-html="details.content"></div>
		<!-- 评论组件 -->
		<comment :id="id"></comment>
	</div>
</template>

<script>
	import comment from '../../publicComponent/comment.vue';
	import { Toast } from 'mint-ui';
	export default {
		data(){
			return {
				id: this.$route.params.id,
				details: {},
				Thumbs: []
			}
		},
		components:{
			comment
		},
		methods: {
			getPhotoDetails(){
				this.$http.get('api/getimageInfo/' + this.id).then(res=>{
					if (res.body.status == 0) {
						this.details = res.body.message[0];
					} else {
						Toast('获取数据失败！');
					}
				})
			},
			getThumbs(){
				this.$http.get(`api/getthumimages/${this.id}`).then(res=>{
					if (res.body.status == 0) {
						this.Thumbs = res.body.message;
					} else {
						Toast('获取图片失败！');
					}
				})
			}
		},
		created(){
			this.getPhotoDetails();
			this.getThumbs();
		}
	}
</script>

<style lang="scss" scoped="scoped">
	.details-container{
		padding: 0 10px;
		h3{
			font-size: 16px;
			text-align: center;
			padding: 15px 0;
			color: #26a2ff;
		}
		p{
			font-size: 13px;
			display: flex;
			justify-content: space-between;
		}
		.details-content{
			font-size: 13px;
			line-height: 30px;
			text-indent: 25px;
		}
		img{
			margin: 5px 5px;
			width: 120px;
			height: 80px;
			box-shadow: 0 0 3px #26A2FF ;
		}
	}
</style>
